package model.tokens;

import java.util.Stack;

import model.parser.Parser;
import model.semantics.Node;

/**
 * Function tokens are all the different functions that we have (plus, minus,
 * perlinColor, etc).
 */

public class FunctionToken<T> extends FunctionalToken<T>
{

	public FunctionToken(String symbol, String syntaxFileName)
	{
		super(symbol, syntaxFileName);
	}

	@Override
	public void process(Stack<Token<T>> operatorStack, Stack<Node<T>> output,
			Parser myParser)
	{
		while (!operatorStack.empty()
				&& operatorStack.peek() instanceof FunctionToken
				&& ((FunctionToken<?>) operatorStack.peek()).getPrecedence() >= getPrecedence()) {
			output.add(((FunctionToken<T>) operatorStack.pop())
					.makeNewInstance(output));
		}
		operatorStack.push(this);
	}

}
